package com.ranjiaqi.function;

import java.util.function.Supplier;

/**
 * @ClassName TestSupplierArrayMax
 * @Description TODO
 * @Author hp
 * @Date 2021/7/5 16:39
 * @Version 1.0
 **/
public class TestSupplierArrayMax {
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        int a =getArrayMax( ()->{
            int max = arr[0];
            for (int x = 1;x<arr.length;x++){
                if (arr[max]<arr[x]){
                    max = x;
                }
            }
            return arr[max];
        });
        System.out.println("a = " + a);
    }
    public static int getArrayMax(Supplier<Integer> supplier){
        return supplier.get();
    }
}
